import request from '@/utils/request';
const getAdderssList = async (pramas = {}) => {
  // const url = $globalRequestUrl({
  // 	url: '/getAddersslist',
  // });
  // return await $globalRequest(url, pramas, { method: 'GET' })
  // 	.then((res) => [res.data, null])
  // 	.catch((err) => [null, err]);
};
const getAddressEdit = async (pramas = {}) => {
  // const url = $globalRequestUrl({
  // 	url: '/getAddressedit',
  // });
  // return await $globalRequest(url, pramas, { method: 'POST' })
  // 	.then((res) => [res.data, null])
  // 	.catch((err) => [null, err]);
};
const getUserInfo = async (pramas = {}) => {
  const url = $globalRequestUrl({
    url: '/user/me',
  });
  return await request({
    url,
    method: 'get',
  })
};
const getGoodsList = async (pramas = {}) => {
  const url = $globalRequestUrl({
    url: '/goods',
  });
  return await request({
    url,
    method: 'get',
  })
};
const getGoodsPay = async (data) => {
  const url = $globalRequestUrl({
    url: '/goods/pay',
  });
  return await request({
    url,
    method: 'post',
    data
  })
};
// 新的梦钥支付
const getGoodsPays = async (data) => {
  const url = $globalRequestUrl({
    url: '/goods/pays',
  });
  return await request({
    url,
    method: 'post',
    data
  })
};
// 新的会员
const getMemberLevelList = async () => {
  const url = $globalRequestUrl({
    url: '/member/me/list',
  });
  return await request({
    url,
    method: 'get',
  })
}
const getUpdatePwd = async (data) => {
  const url = $globalRequestUrl({
    url: '/user/me/pwd',
  });
  return await request({
    url,
    method: 'post',
    data
  })
};

const getSettings = async () => {
  const url = $globalRequestUrl({
    url: '/system/setting?key=admin_qq',
  });
  return await request({
    url,
    method: 'get',
  })
};
const getUpdateUserInfo = async (data) => {
  const url = $globalRequestUrl({
    url: '/user/me/edit',
  });
  return await request({
    url,
    method: 'post',
    data
  })
};

// 获取用户消息列表
const getTickets = async () => {
  const url = $globalRequestUrl({
    url: '/tickets',
  });
  return await request({
    url,
    method: 'get',
  })
};
// 发送工单消息
const sendTicketMessage = async (data) => {
  const url = $globalRequestUrl({
    url: '/tickets/create',
  });
  return await request({
    url,
    method: 'post',
    data
  })
}
// 删除所有消息
const deleteAllTicketMessage = async () => {
  const url = $globalRequestUrl({
    url: '/tickets/delete',
  });
  return await request({
    url,
    method: 'post',
  })
}
// 获取梦钥记录
const getDiamondRecords = async (params) => {
  const url = $globalRequestUrl({
    url: '/diamond/transaction',
  });
  return await request({
    url,
    method: 'get',
    params
  })
}
// 获取会员列表
const getMemberLevel = async (params) => {
  const url = $globalRequestUrl({
    url: '/member/level',
  });
  return await request({
    url,
    method: 'get',
    params
  })
}
// 获取充值列表
const getDiamondRechargePlan = async () => {
  const url = $globalRequestUrl({
    url: '/diamond/recharge/plan',
  });
  return await request({
    url,
    method: 'get',  
  })
}

const getInvited = async () => {
  const url = $globalRequestUrl({
    url: '/user/invited',
  });
  return await request({
    url,
    method: 'get',
  })
}
const getCommonSettingsByKeys = async (key) => {
  const url = $globalRequestUrl({
    url: `/system/setting?key=${key}`,
  });
  return await request({
    url,
    method: 'get',
  })
};
const getMemberRights = async () => {
  const url = $globalRequestUrl({
    url: `/member/rights`,
  });
  return await request({
    url,
    method: 'get',
  })
}

// 获取通知消息列表
const getNotifications = async (page = 1, pageSize = 10) => {
  const url = $globalRequestUrl({
    url: `/notifications`,
  });
  return await request({
    url,
    method: 'get',
    params: {
      page,
      per_page: pageSize
    }
  })
}

export { getAdderssList, getAddressEdit, getUserInfo, getGoodsList, getGoodsPay, getUpdatePwd, getSettings, getUpdateUserInfo, getTickets, sendTicketMessage, deleteAllTicketMessage, getDiamondRecords, getMemberLevel, getDiamondRechargePlan, getGoodsPays, getMemberLevelList, getInvited,getCommonSettingsByKeys,getMemberRights, getNotifications };
